package com.tanhua.manage.controller;

import com.tanhua.manage.service.UserDistributionJunService;
import com.tanhua.manage.vo.UserDistributionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * jun
 */
@RestController
@RequestMapping("dashboard")
public class UserDistributionJunController {

    @Autowired
    private UserDistributionJunService userDistributionJunService;

    /**
     *  用户注册分布
     *
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("distribution")
    public ResponseEntity<UserDistributionVo> UserDistributionJun(@RequestParam(value = "sd")Long startTime,
                                                                  @RequestParam(value = "ed")Long endTime){

        try{
            UserDistributionVo userDistributionVo = this.userDistributionJunService.UserDistributionJun(startTime, endTime);
            if (null != userDistributionVo){
                return ResponseEntity.ok(userDistributionVo);
            }
        } catch (Exception e){
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
